import 'package:cgvc/model/app_update_model.dart';
import 'package:cgvc/data/update_http.dart';
import 'package:cgvc/util/platform_util.dart';
import 'package:flustars/flustars.dart';

class UpdateRepository {
  static Future<AppUpdateModel> checkUpdate() async {
    var response = await http.post('app/check');
    var result = AppUpdateModel.fromJson(response.data);
    result.buildHaveNewVersion = result.buildHaveNewVersion &&
        await PlatformUtil.getBuildNumber() != result.buildVersionNo;
    if (result.buildHaveNewVersion) {
      LogUtil.v('checkUpdate->发现新版本->v${result.buildVersion}');
      return result;
    }
    return null;
  }
}
